<?php
if ( !defined('IN_ADMINCP') || !defined('IN_SEC') ){
	exit('Access Denied.');
}
$act = $_G['gp_act'];

if( $act == 'get_departments' ){
	jsonp($departments, 'data');
}else if( $act == 'delete' ){
	if( !$id ){
		$admincp->cpmsg('部门不存在');
	}
	$member = fetch('admincp_member', $id, 'departmentid');
	if( $member ){
		$admincp->cpmsg('该部门有未移除的成员');
	}
	delete('admincp_department', $id);

	$admincp->log('admincp_department', $id, '删除部门：' . $department['name'], 'delete');
	Session::Set('notice', '操作成功');
	$admincp->json_type('refresh');
	$admincp->success();
	jsonp('操作成功');
}

?>